package com.pdsu.xpf.graduation01.dao;

import com.pdsu.xpf.graduation01.domain.CommodityType;
import com.pdsu.xpf.graduation01.dto.OrderDTO;
import com.pdsu.xpf.graduation01.dto.PayCommodityDTO;
import com.pdsu.xpf.graduation01.vo.OrderVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IOrderDao {


    @Insert("insert into user_order(uid,cid,cname,ucnumber,cimage,order_number,state,create_time) values (#{uid},#{cid},#{cname},#{cnumber},#{image},#{orderNumberByTime},'n',#{date})")
    Integer createOrder(int uid, int cid, String cname, int cnumber, String image, String orderNumberByTime,String date);


    @Select("SELECT uo.create_time,uo.state, uo.order_number,co.cid ,co.uid,co.cname,co.sell_desc,uo.ucnumber,co.price,co.username,co.image,co.cmessage,co.cnumber from commodity as co , user_order as uo where uo.uid = #{uid} AND co.cid = uo.cid")
    List<OrderDTO> getOrderDTOListByOrderUID(int  uid);

    @Select("select * from user_order as ord, user ,commodity where ord.uid = user.uid and ord.cid = commodity.cid")
    List<OrderVO> findAllOrderVO();

    @Delete("delete from user_order where oid = #{oid}")
    int delOrderByOID(int oid);
    //

    @Select("select * from user_order where order_number like #{key}")
    List<OrderVO> searchOrderByKey(String key);

    @Update("update user_order set state = 'd' where order_number = #{order_number} ")
    Integer updateOrderStateByOrderNumber(String order_number);
}
